<?php require_once 'header.php'; ?>
<script type="text/javascript" src="<?=base_url()?>js/tinymce/tinymce.min.js"></script>
<script>
tinymce.init({
    selector: "#topic_news_desc",
    theme: "modern",
    width: 550,
    height: 300,
    plugins: [
         "advlist autolink link image lists charmap print preview hr anchor pagebreak spellchecker",
         "searchreplace wordcount visualblocks visualchars code fullscreen insertdatetime media nonbreaking",
         "save table contextmenu directionality emoticons template paste textcolor"
   ],
   content_css: "css/content.css",
   toolbar: "insertfile undo redo | styleselect | bold italic | alignleft aligncenter alignright alignjustify | bullist numlist outdent indent | l      ink image | print preview media fullpage | forecolor backcolor emoticons", 
   style_formats: [
        {title: 'Bold text', inline: 'b'},
        {title: 'Red text', inline: 'span', styles: {color: '#ff0000'}},
        {title: 'Red header', block: 'h1', styles: {color: '#ff0000'}},
        {title: 'Example 1', inline: 'span', classes: 'example1'},
        {title: 'Example 2', inline: 'span', classes: 'example2'},
        {title: 'Table styles'},
        {title: 'Table row 1', selector: 'tr', classes: 'tablerow1'}
    ]
 }); 
tinymce.init({
    selector: "#topic_news_content",
    theme: "modern",
    width: 550,
    height: 300,
    plugins: [
         "advlist autolink link image lists charmap print preview hr anchor pagebreak spellchecker",
         "searchreplace wordcount visualblocks visualchars code fullscreen insertdatetime media nonbreaking",
         "save table contextmenu directionality emoticons template paste textcolor"
   ],
   content_css: "css/content.css",
   toolbar: "insertfile undo redo | styleselect | bold italic | alignleft aligncenter alignright alignjustify | bullist numlist outdent indent | l      ink image | print preview media fullpage | forecolor backcolor emoticons", 
   style_formats: [
        {title: 'Bold text', inline: 'b'},
        {title: 'Red text', inline: 'span', styles: {color: '#ff0000'}},
        {title: 'Red header', block: 'h1', styles: {color: '#ff0000'}},
        {title: 'Example 1', inline: 'span', classes: 'example1'},
        {title: 'Example 2', inline: 'span', classes: 'example2'},
        {title: 'Table styles'},
        {title: 'Table row 1', selector: 'tr', classes: 'tablerow1'}
    ]
 }); 
</script>
<link rel="stylesheet" href="<?= base_url() ?>styles/datepicker/themes/base/jquery.ui.all.css" type="text/css" media="screen" charset="utf-8" />
<script src="<?php echo base_url() ?>styles/datepicker/ui/jquery.ui.core.js"></script>
<script src="<?php echo base_url() ?>styles/datepicker/ui/jquery.ui.widget.js"></script>
<script src="<?php echo base_url() ?>styles/datepicker/ui/jquery.ui.datepicker.js"></script>

<div id="content" class="col-lg-9 clearfix">
    <script type="text/javascript">
        function setError(fieldname) {
            $("." + fieldname + "class").addClass("field-error");
        }	
        function validate()
        {
            var next = true;
            if(document.upload_form.name.value == "") {
                setError("name");
                next = false;
            }
            if(document.upload_form.url.value == "") {
                setError("url");
                next = false;
            } 
	
            if(next) return true;
            else { alert("Vui lòng nhập đủ thông tin"); return false;}
        }
                
    </script>
    <?php if (isset($error)): ?>
        <p class="error"><?= $error ?></p>
    <?php endif; ?>	
    <?php if (isset($success)): ?>
        <p class="success"><?= $success ?></p>
    <?php endif; ?>	
    <h2>Thêm mới topic</h2>		
    <form name="upload_form" method="post" action="<?php echo site_url('qlquangcao/edit').'/'.$id; ?>" enctype="multipart/form-data">
        <div style="float:left;width:500px;">
            <table align="center">
                <tr>
                    <td><h6 class="topic_news_titleclass">Ads name</h6></td>
                    <td><input type="text" name="ads_name" value="<?=$quangcao->ads_name ?>" size="40" /></td>
                </tr>
                <tr>
                    <td><h6>Quảng cáo link</h6></td>
                    <td>
                       <input type="text" name="link" value="<?=$quangcao->link ?>"/>
                    </td>
                </tr> 
                <tr>
                    <td><h6>Giá quảng cáo</h6></td>
                    <td>
                       <input type="text" name="price" value="<?=$quangcao->price; ?>"/>
                    </td>
                </tr>
                <tr>
                    <td><h6>Kiểu quảng cáo</h6></td>
                    <td>
                       <input type="text" name="type" value="<?=$quangcao->type?>"/>
                    </td>
                </tr>   
                  <tr>
                    <td><h6>section quảng cáo</h6></td>
                    <td>
                       <input type="text" name="section" value="<?=$quangcao->section?>"/>
                    </td>
                </tr>  
                 <tr>
                    <td><h6>Page quảng cáo</h6></td>
                    <td>
                       <input type="text" name="page" value="<?=$quangcao->page?>"/>
                    </td>
                </tr>  
                <!-- <tr>
                    <td><h6>Ngày đăng</h6></td>
                    <td>
                        <input type="text" name="topic_news_date" id="date_datepicker"/>
                    </td>
                </tr>   --> 
                <tr>
                    <td><h6>Upload ảnh</h6></td>
                    <td>
                        <img src="<?=base_url().$quangcao->image?>" width="145px" height="120px" />
                        <input type="file" name="image" size="30" /></td>
                </tr>	
               
             
                <tr>
                    <td><h6>Action</h6></td>
                    <td>
                        <input type="reset" value="Reset"/>
                        <input type="submit" value="Update" name="update" onclick="return validate();" />
                    </td>
                </tr>		
            </table>
        </div>
        <script>
                // $(function(){
                //     $("#date_datepicker").datepicker();
                // });
        </script>
    </form>
</div>
<?php require_once 'footer.php'; ?>